package org.dxy.domain.model.aggregate;

import org.dxy.domain.command.equipment.*;
import org.dxy.domain.command.workorder.*;
import org.dxy.domain.model.aggregate.impl.WorkOrderAggRoot;
import org.dxy.domain.model.valobj.WorkOrderId;
import org.dxy.domain.model.valobj.WorkOrderStatusEnum;

/**
 * @description: 工单聚合根接口
 * @author: dxy 
 * @createTime: 2025/6/22 17:26 
 */
public interface WorkOrder extends AggregateRoot {

    WorkOrderId getWorkOrderId();
    String getWorkOrderCode();
    String getProductModel();
    Integer getPlannedQuantity();
    WorkOrderStatusEnum getStatus();

    /**
     * 创建工单
     */
    static WorkOrder create(Long workOrderId, CreateWorkOrderCommand command) {
        return WorkOrderAggRoot.create(workOrderId, command);
    }

    /**
     * 下达工单
     */
    void release(ReleaseWorkOrderCommand command);

    /**
     * 开始生产
     */
    void start(StartWorkOrderCommand command);

    /**
     * 暂停工单
     */
    void suspend(SuspendWorkOrderCommand command);

    /**
     * 恢复工单
     */
    void resume(ResumeWorkOrderCommand command);

    /**
     * 完成工单
     */
    void complete(CompleteWorkOrderCommand command);

    /**
     * 关闭工单
     */
    void close(CloseWorkOrderCommand command);

    /**
     * 取消工单
     */
    void cancel(CancelWorkOrderCommand command);

    /**
     * 设备故障任务重分配
     */
    void reassignTaskDueToFailure(ReassignTaskDueToFailureCommand command, Equipment original, Equipment target);

    /**
     * 更新工单信息
     */
    void update(String workOrderCode, String productModel, Integer plannedQuantity, String routeCode, String productionLineCode);

    /**
     * 删除工单
     */
    void delete();

    /**
     * 检查是否可以更新
     */
    boolean canUpdate();

    /**
     * 检查是否可以删除
     */
    boolean canDelete();
}

